<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <input type="text" v-model = "firstName">
    <input type="text" v-model = "latName">

    计算属性:{{getName}}
    <button @click = "setatri ">点击</button>
  </div>
  <script>
    Vue.config.productionTip = false;
    
    const vm = new Vue({
      el: "#app",
      data() {
        return {
          firstName: '',
          latName: '',
        }
      },
      //计算属性配置
      computed:{
        getName:{
          //获取属性的时候执行
          get(){
            console.log("get执行了");
            return this.firstName + '--' + this.latName
          },
          //设置属性的时候执行
          set(vale){
            console.log("set执行了");
            this.firstName = vale
          }
        }
      },
      //函数
      methods:{
        setatri(){
          this.getName = "666"
        }
      }
    })
  </script>
</body>

</html>